package com.javaex.book.pojo;

import java.math.BigDecimal;

/**
 * 购物车商品项
 *
 * @author 黄星琦
 * @Date 2022年2月27日
 */
public class CartItem {

	/** 商品编号 */
	private Integer id;
	
	/** 商品名称 */
	private String name;
	
	/** 商品数量 */
	private Integer count;
	
	/** 商品单价 */
	private BigDecimal price;
	
	public CartItem() {
	}

	public CartItem(Integer id, String name, Integer count, BigDecimal price) {
		this.id = id;
		this.name = name;
		this.count = count;
		this.price = price;
	}

	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public Integer getCount() {
		return count;
	}
	
	public void setCount(Integer count) {
		this.count = count;
	}
	
	public BigDecimal getPrice() {
		return price;
	}
	
	public void setPrice(BigDecimal price) {
		this.price = price;
	}
	
	public BigDecimal getTotalPrice() {
		return price.multiply(new BigDecimal(count));
	}
	
	@Override
	public String toString() {
		return "CartItem [id=" + id + ", name=" + name + ", count=" + count + ", price=" + price + ", totalPrice=" + getTotalPrice() + "]";
	}
}
